package com.future.taglib

import java.util.regex.Pattern

class ParseHtmlTagLib {
  def subString = {attrs ->
    String htmlStr = attrs.string; // 含html标签的字符串
    def len = attrs.sublength
    if (htmlStr == null) {
      htmlStr = "没有录入数据！";
    }
    if (len == null) {
      len = htmlStr.length();
    }
    try {
      if (htmlStr.length() >= (len - 1)) {
        htmlStr = htmlStr.substring(0, (len - 1));
      }
    } catch (Exception e) {
      println e
      out << "<script>alert('输入格式有误！');</script>"
    }
    println ">>" + htmlStr
    out << htmlStr;// 返回文本字符串
  }
}